package componentes;

import com.uqbar.metalGear.MGSScene;
import com.uqbar.vainilla.DeltaState;

import comportamiento.ControlesPJ;

public class Coordenada {
	
	private double cx;
	private double cy;
	private double cxAnterior;
	private double cyAnterior;
	private ControlesPJ controles;
	private double velocidad;
	
	public Coordenada(double cx, double cy, ControlesPJ controles, double velocidad){
		this.cx = cx;
		this.cy = cy;
		this.controles = controles;
		this.velocidad = velocidad;
	}
	
	public void update(DeltaState deltaState, MGSScene scene) {
		
		this.setCyAnterior(this.getCy());
		this.setCxAnterior(this.getCx());
		this.controles.updateCoordenada(this, scene, deltaState);
		
		//System.out.println("cx " +this.getCx());
		
	}
	
	public void retroceder(){
		this.setCx(this.getCxAnterior());
		this.setCy(this.getCyAnterior());
	}
	
	public void derecha(double delta) {
		this.setCx(this.getCx() - getVelocidad()*delta);
	}
	
	public void izquierda(double delta) {
		this.setCx(this.getCx() + getVelocidad()*delta);
	}
	
	public void abajo(double delta){
		this.setCy(this.getCy() - getVelocidad()*delta);	
	}
	
	public void arriba(double delta) {
		this.setCy(this.getCy() + getVelocidad()*delta);
	}
	
	public double getCx() {
		return cx;
	}
	public void setCx(double cx) {
		this.cx = cx;
	}
	public double getCy() {
		return cy;
	}
	public void setCy(double cy) {
		this.cy = cy;
	}

	public double getCxAnterior() {
		return cxAnterior;
	}

	public void setCxAnterior(double cxAnterior) {
		this.cxAnterior = cxAnterior;
	}

	public double getCyAnterior() {
		return cyAnterior;
	}

	public void setCyAnterior(double cyAnterior) {
		this.cyAnterior = cyAnterior;
	}

	public ControlesPJ getControles() {
		return controles;
	}

	public void setControles(ControlesPJ controles) {
		this.controles = controles;
	}

	public double getVelocidad() {
		return velocidad;
	}

	public void setVelocidad(double velocidad) {
		this.velocidad = velocidad;
	}
	
}
